/** head.cpp, migrated from head.c from coreutils
 * head -- output first part of file(s)
 * Copyright (C) 1987-2020 Free Software Foundation, Inc.
 * Migrated C++ code Copyright (C) Todd Saharchuk, 2020.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Original Authors:
 * David MacKenzie
 * Jim Meyering
 *
 * C++ Code migration:
 * Todd Saharchuk <tsaharchuk1@athabasca.edu> @northerntechie
 */

// C++ includes
#include <iostream>
#include <map>
#include <string>
#include "docopt/docopt.h"
#include "globals.h"
// End of C++ includes

/* The official name of this program (e.g., no 'g' prefix).  */
#define PROGRAM_NAME head

#define VERSION F_VERSION(PROGRAM_NAME)

constexpr auto USAGE =
R"(head.

     Usage:
       head [options] [FILE...]

       Print the first %d lines of each FILE to standard output.
         With more than one FILE, precede each with a header giving the file name.

     Options:
       -h --help              Show this screen
       --version              Show version
       -c, --bytes=[-]NUM     Print the first NUM bytes of each file;
                                with the leading '-', print all but the last
                                NUM bytes of each file
       -n, --lines=[-]NUM     Print the first NUM lines instead of the first %d;
                                with the leading '-', print all but the last
                                NUM lines of each file
       -q, --quiet, --silent  Never print headers giving file names
       -v, --verbose          Always print headers giving file names
       -z, --zero-terminated  Line delimiter is NUL, not newline

     Notes:

       NUM may have a multiplier suffix:
         b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
         GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
         Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
)";

int main(int argc, char** argv)
{
  std::map<std::string, docopt::value> args =
      docopt::docopt (USAGE,
                      {argv + 1, argv + argc},
                      true,
                      VERSION);

  // TODO(@northerntechie): Finish implementation
  for (auto kv : args)
    {
      std::cout << kv.first << " : " << kv.second << "\n";
    }

  std::cout << "Implementation incomplete! Do not use!\n";

  return EXIT_SUCCESS;
}
